<template>
	<view class="container">
		<rich-text :nodes="content"></rich-text>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		getSetting
	} from '@/api/index'

	const lang = ref(uni.getStorageSync('locale') || "zh-Hant"); // 当前语言
	const content = ref(""); // 富文本内容

	const collectData = reactive({
		"zh-Hant-about_us": {
			title: "關於我們",
			params: "about_us_zh"
		},
		"en-about_us": {
			title: "About Us",
			params: "about_us_en"
		},
		"zh-Hant-help": {
			title: "幫助指南",
			params: "help_zh"
		},
		"en-help": {
			title: "Help Guide",
			params: "help"
		},
		"zh-Hant-sharing": {
			title: "代理規則",
			params: "sharing_zh"
		},
		"en-sharing": {
			title: "Proxy rules",
			params: "sharing"
		},
		"zh-Hant-recommendation": {
			title: "推薦規則",
			params: "recommendation_zh"
		},
		"en-recommendation": {
			title: "Recommendation rules",
			params: "recommendation"
		},
		"zh-Hant-rechargeRules": {
			title: "儲值規則",
			params: "rechargeRules_zh"
		},
		"en-rechargeRules": {
			title: "Value storage rules",
			params: "rechargeRules"
		},
	});

	onLoad((options) => {
		let formData = collectData[`${lang.value}-${options.type}`]
	
		uni.setNavigationBarTitle({
			title: formData.title
		});
		
		// 获取通用配置
		getSetting({
			codes: [formData.params]
		}).then((res) => {
			content.value = res.data.setting[formData.params]
		})
	})
</script>

<style lang="scss" scoped>
.container {
	padding: 20rpx;
	box-sizing: border-box;
}
</style>